/*
 * =====================================================================================
 *
 *       Filename:  time_ut.cxx
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  10/12/2010 07:25:33 PM
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Chen Ken (Ken), zlchen.ken@gmail.com
 *        Company:  EMC
 *
 * =====================================================================================
 */

#define BOOST_TEST_MODULE utils_ut 
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>

#include "cl_timer.hxx"
#include "cl_timestamp.hxx"

using namespace std;
using namespace neo;
void Print()
{
}

BOOST_AUTO_TEST_SUITE(time_ut)

BOOST_AUTO_TEST_CASE(timestamp_test)
{
  CLTimestamp time1(CLTimestamp::nowTime());
  CLTimestamp time2 = time1;
  time2 += Second(2);
	BOOST_CHECK(time2 > time1);
	BOOST_CHECK((time2 == time1) == false);
	BOOST_CHECK((time2 < time1) == false);
	BOOST_CHECK((time2 == time1 + Second(2)));
	BOOST_CHECK((time1 < CLTimestamp::nowTime()));
  cout << time1 << "\n";
  cout << time2 << "\n";
  cout << CLTimestamp::nowTime() << "\n";
}

BOOST_AUTO_TEST_CASE(timer_test)
{
  Second interval(2);
  CLTimestamp ts(CLTimestamp::nowTime());
	std::shared_ptr<CLTimer> timer1(CLTimer::create(bind(Print), ts, interval.toMicroSecond()));
	BOOST_CHECK(timer1->isRepeated());
	BOOST_CHECK(timer1->isExpired());
}

BOOST_AUTO_TEST_SUITE_END()

